var express = require('express');
var router = express.Router();
var fs = require('fs');
var path = require('path');
let rootPath = path.dirname(__dirname);

router.get('/anime', function (req, res) {
  let { video } = req.query;

  let head = { 'Content-Type': 'video/mp4' };
  //需要设置HTTP HEAD
  res.writeHead(200, head);
  //使用pipe
  fs.createReadStream(`${rootPath}/public/video/${video}`).pipe(res);
});
module.exports = router;
